<template>
	<view class="main">
		<view class="card_box">
			<view class="card_content"  @click="goTemplate">
				<view class="title">
					{{title}}
				</view>
				<view class="bottom">
					<view class="bt_title">
						 查看问卷详情
					</view>
					<view class="bt_arrow">
						<u-icon name="arrow-right" color="#ccc" size="36"></u-icon>
					</view>
				</view>
			</view>

			<view class="card_content" v-for="(n,k) in lists" @click="goDetails(n)">
				<view class="title">
					<view class="">
						（{{n.nickName}}<span style="color:#36B278">@{{myType(n.type)}}</span>)
					</view>
					<view class="time">
						{{n.quesFillTime}} 已填写
					</view>
				</view>
				<view class="bottom">
					<view class="bt_title">
						 查看问卷详情
					</view>
					<view class="bt_arrow">
						<u-icon name="arrow-right" color="#ccc" size="36"></u-icon>
					</view>
				</view>
			</view>
		</view>
		<go-nav></go-nav>
	</view>
</template>

<script>
	import {
		wenjuanDetails
	} from '@/api/index.js'
	export default {
		data() {
			return {
				lists: [],
				topData:'',
				id: '',
				title: ''
			};
		},
		onLoad(obj) {
			if (obj.id) {
				this.id = obj.id
				this.title = obj.title
				this.getData()
			}
		},
		computed:{
			myType(val){
				return (val)=>{
					if(val == 1) return '微信'
					if(val == 2) return '企业微信'
					return '微信'
				}
			}
		},
		onShow() {

		},
		methods: {
			async getData() {
				let res = await wenjuanDetails(this.id)
				this.lists = res.quesFillCustomerList
				this.topData = res.quesInfo
				
				console.log(res, 'res');
			},
			goTemplate(){  //问卷详情，未填写
				window.location.href = this.topData.previewUrl
			},
			async goDetails(obj) {
				window.location.href = obj.quesResultUrl
				//console.log(obj);
				//let res = await
			}
		},
	}
</script>

<style lang="scss" scoped>
	.main {
		background-color: #f8f8f8;
		min-height: 100vh;

		.card_box {
			padding-top: 20rpx;

			.card_content {
				border-radius: 20rpx;
				margin: 0 24rpx 24rpx 24rpx;
				background-color: white;

				.title {
					padding: 32rpx 24rpx;
					font-weight: bold;
					font-size: 32rpx;
					color: #212121;
					line-height: 38rpx;
					border-bottom: 1px dashed #e8e8e8;

					.time {
						padding-top: 12rpx;
						font-size: 28rpx;
						font-weight: 400;
						color: #999999;
						line-height: 33rpx;
					}
				}

				.bottom {
					display: flex;
					align-items: center;
					padding: 16rpx 24rpx;
					justify-content: space-between;

					.bt_title {
						font-weight: 400;
						font-size: 28rpx;
						color: #666666;
						line-height: 33rpx;
					}

					.bt_arrow {}
				}
			}

		}
	}
</style>